from selenium import webdriver
from time import sleep

from selenium.webdriver.common.by import By

#多元素定位
driver= webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://192.168.1.138/ranzhi/www/sys/user-login-L3JhbnpoaS93d3cvc3lzL2luZGV4Lmh0bWw=.html")
driver.maximize_window()
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[1]/div/div/button').click()
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[1]/div/div/ul/li[1]/a').click()
sleep(3)
driver.find_element("id","account").send_keys("admin")
driver.find_element("id","password").send_keys("123456")
driver.find_element("id","keepLoginon").click()
driver.find_element("id","submit").click()
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button/i').click()
#框架的切入 : driver.switch_to.frame("iframe_superadmin")
driver.switch_to.frame("iframe-superadmin")
driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div[1]/div/a/h3').click()
sleep(3)
#下拉框操作
from selenium.webdriver.support.select import Select
#定位到下拉框
ele=driver.find_element(By.ID,"role")
#创建下拉框对象
sle_obj=Select(ele)
#调用方法
# sle_obj.select_by_index(3)
# sle_obj.select_by_visible_text("市场主管")
sle_obj.select_by_value("top")
sleep(2)
#返回根框架
driver.switch_to.parent_frame() #返回上一级框架
# driver.switch_to.default_content() #返回根框架
driver.find_element(By.LINK_TEXT,"签退").click()
sleep(2)
driver.quit()


